<?php
namespace AdminApi\Controller;
use Zend\Mvc\Controller\AbstractRestfulController;
use Zend\View\Model\JsonModel;
class ComplaintsApiController extends AbstractRestfulController
{
    public function getList()
    {
		header('Access-Control-Allow-Origin: *');
		$userMedicineOrderTable=$this->getServiceLocator()->get('Models\Model\ComplaintsFactory');
		$AllComplaints = $userMedicineOrderTable->getAllComplaints()->toArray();
		if(count($AllComplaints)!=0){
				return new JsonModel(array(
					'value'			=>	1,
					'result'			=> json_encode($AllComplaints),
				));
			}else{
				return new JsonModel(array(
					'value'			=>	0,
				));
			}
    }
    public function get($status)
    {	
		header('Access-Control-Allow-Origin: *');
		$userMedicineOrderTable=$this->getServiceLocator()->get('Models\Model\UserMedicineOrderFactory');
		$explodeId=explode('-',$status);
		$status=$explodeId[0];
		$allUserOrders = $userMedicineOrderTable->getAllAdminOrders($status);
		if($allUserOrders->count()){
			return new JsonModel(array(
				'value'			=> 1,
				'result'		=> json_encode($allUserOrders->toArray()),
			));
		}else{
			return new JsonModel(array(
				'value'			=>'0',
				'orders'		=> 	'Orders list is empty',
			));
		}
    }
    public function create($oder)
    {
		
    }
    public function update($order_id,$order)
    {
		
	}		
    public function delete($id)
    {
       
    }
}